package HUZ_FileIO;

import java.io.*;
import java.nio.charset.Charset;

public class demo4 {
    public static void main(String[] args) throws IOException {
        File file=new File("E:\\Java网络通信程序\\TestDemo1\\file.txt");
        //包装输入流对象
        InputStream InputStream=new FileInputStream(file);
        //为了解决不同设备的读写速率(进一步将输入流对象封装成缓冲输入流对象)
        BufferedInputStream bufferedInputStream=new BufferedInputStream(InputStream);
//        int b=0;
//        while(b!=-1){
//            b=bufferedInputStream.read();
//            System.out.printf("%c",(char)b);
//            //System.out.println(b);
//        }

        byte[]arr=new byte[1024];
        int byteLength = bufferedInputStream.read(arr);
        String context=new String(arr, 0,byteLength,"utf8");
        System.out.println(context);

    }
}
